

lift <- function(topic, n) {
  theta <- topic/(rowSums(topic) + 1e-05)
  empprob <- colSums(topic)/sum(topic)
  outmat <- matrix(NA, n, K)
  for(i in 1:nrow(theta)) {
    outmat[,i] <- colnames(topic)[order(theta[i,]/empprob, decreasing=T)[1:n]]
  }
  return(outmat)
}